package com.myph.phctrl_t;

import com.example.phctrl_t.R;

import android.R.integer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class SelectFunctionActivity extends Activity implements OnClickListener {
    Button btn_signal, btn_measure, btn_sensor_switch, btn_sleep_switch,
            btn_setTime,btn_setGapTime;
    String ip, port;
	private long prevClickTime = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_selectfunction);
        btn_signal = (Button) findViewById(R.id.btn_signal);
        btn_measure = (Button) findViewById(R.id.btn_measure);
        btn_sensor_switch = (Button) findViewById(R.id.btn_sensor_switch);

        btn_setTime = (Button) findViewById(R.id.btn_setTime);
        btn_sleep_switch = (Button) findViewById(R.id.btn_sleep_switch);
        btn_setGapTime = (Button) findViewById(R.id.btn_setGapTime);
        
        
        btn_sleep_switch.setOnClickListener(this);
        btn_setTime.setOnClickListener(this);
        btn_signal.setOnClickListener(this);
        btn_measure.setOnClickListener(this);
        btn_sensor_switch.setOnClickListener(this);
        btn_setGapTime.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
    	long pressGap = System.currentTimeMillis() - prevClickTime ;
		if(pressGap < 1000){
			return;
		}else{
			prevClickTime = System.currentTimeMillis();
		}
        switch (view.getId()) {
        case R.id.btn_signal:
            Intent intent1 = new Intent(getApplicationContext(),
                    SignalActivity.class);
            startActivity(intent1);
            break;
        case R.id.btn_measure:
            Intent intent2 = new Intent(getApplicationContext(),
                    MeasureActivity.class);
            startActivity(intent2);
            break;
        case R.id.btn_sensor_switch:
            Intent intent3 = new Intent(getApplicationContext(),
                    SensorActivity.class);
            startActivity(intent3);
            break;
        case R.id.btn_sleep_switch:
            Intent intent4 = new Intent(getApplicationContext(),
                    MCUSleepActivity.class);
            startActivity(intent4);
            break;
        case R.id.btn_setTime:
            Intent intent5 = new Intent(getApplicationContext(),
                    SetMCUTimeActivity.class);
            startActivity(intent5);
            break;
        case R.id.btn_setGapTime:
        	Intent intent6 = new Intent(getApplicationContext(),SetGapTimeActivity.class);
        	startActivity(intent6);
        default:
            break;
        }
    }
}
